<?php
    $aMemberListData = pg_query($oSql, "SELECT * FROM membre");

    function afficheVueEnssemble($edvar, $oSql) {
        echo '<h3> Edition : ' . $edvar . ' </h3>';
        ?>
        <table style="width: 100%; margin: 10px auto 30px auto;">
            <tr>
                <th class="palette palette-firm">Nom</th>
                <th class="palette palette-firm">Prenom</th>
                <th class="palette palette-firm">pseudo</th>
                <th class="palette palette-firm">classement</th>
            </tr>
            <?php
            $vSql = "SELECT * from participation natural join membre where edition='" . $edvar . "'";
            $vQuery = pg_query($oSql, $vSql);
            while ($vResult = pg_fetch_array($vQuery)) {
                echo '<tr>';
                echo '  <td class="palette palette-clouds">' . $vResult['nom'] . '</td>';
                echo '  <td class="palette palette-clouds">' . $vResult['prenom'] . '</td>';
                echo '  <td class="palette palette-clouds">' . $vResult['pseudo'] . '</td>';
                echo '  <td class="palette palette-clouds">' . $vResult['classement'] . '</td>';
                echo '</tr>';
            }
            ?>
        </table>
        <?php
        echo '<br/>';
    }

    function afficheRound($roundvar, $roundnumber, $oSql) {
        if ($roundvar != null) {
            $vSql = "SELECT m1.nom as nomj1,m1.prenom as prenomj1, m1.pseudo as pseudoj1, m2.nom as nomj2,m2.prenom as prenomj2, m2.pseudo as pseudoj2 , duree, to_char(dateheure, 'YYYY/MM/DD HH24:MI:SS') as dateheure,pointegerj1,pointegerj2,numero
                        from match join membre as m1 on match.j1pseudo = m1.pseudo join membre as m2 on match.j2pseudo = m2.pseudo where dateheure='" . $roundvar . "'";
            $vQuery = pg_query($oSql, $vSql);
            while ($vResult = pg_fetch_array($vQuery)) {
                echo '<u>Round ' . $roundnumber . '</u> (numero ' . $vResult['numero'] . ' à ' . $vResult['dateheure'] . ') : <br/>'; //date("Y-m-d H:i:s",$vResult['dateheure'])
                echo 'Match entre ' . $vResult['prenomj1'] . ' ' . $vResult['nomj1'] . ' (' . $vResult['pseudoj1'] . ') et ' . $vResult['prenomj2'] . ' ' . $vResult['nomj2'] . ' (' . $vResult['pseudoj2'] . ')<br/>';
                echo 'durée : ' . $vResult['duree'] . ' min<br/>';
                echo $vResult['prenomj1'] . ' ' . $vResult['nomj1'] . ' ' . $vResult['pointegerj1'] . ' points<br/>';
                echo $vResult['prenomj2'] . ' ' . $vResult['nomj2'] . ' ' . $vResult['pointegerj2'] . ' points<br/>';
            }
        } else {
            echo '<u>Round ' . $roundnumber . '</u> Ce joueur n\'a pas joué ce round <br/>';
        }
        echo '<br/>';
    }
?>
